<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script type="text/javascript">
    let string = "红心海贼团"
    // let number = 18 
    let person = {
        name : "特拉法尔加.D.瓦特尔.罗",
        DevilFruit : "手术果实"
    }
    Object.defineProperty(person,'nickname',{
        // value:"死亡外科医生",
        // enumerable:true,
        // writable:true,
        // configurable:true,
        
        get(){
            return string
        },
        set(val){
            string = val
        }
    })
    console.log(person);

    </script>
</body>
</html>
<!-- 第一次报错 单词错-->
<!-- Uncaught TypeError: Property description must be an object: n
    at Function.defineProperties (<anonymous>)
    at Object.defineProperty.html:15 -->
    <!--第二次错误  注销 value enumerable...-->
    <!-- Object.defineProperty.html:16 Uncaught TypeError: Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>
    at Function.defineProperty (<anonymous>)
    at Object.defineProperty.html:16 -->